package com.zxm.ex.common.test;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class T2 implements Runnable{


    private static int count=0;

    private static Object lock=new Object();
    public static void main(String[] args) throws InterruptedException {
        T2 t2 = new T2();
        log.error("21321321");
        log.info("66666666666----------++++++++");
        new Thread(t2,"偶数").start();
       // Thread.sleep(100);
        new Thread(t2,"奇数").start();
    }

    @Override
    public void run() {
        while (count<100){
            synchronized (lock){
                System.out.println(Thread.currentThread().getName()+ ":"+count++);
                lock.notify();
                if(count<100){
                    try {
                        lock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
